package l1j.server.server.clientpackets;

import l1j.server.echo.ClientThread;
import l1j.server.server.model.Instance.L1PcInstance;

import java.util.logging.Level;
import java.util.logging.Logger;
// Referenced classes of package l1j.server.server.clientpackets:
// ClientBasePacket

/**
 * 處理收到由客戶端傳來結束 ghost 狀態的封包
 */
public class C_ExitGhost extends ClientBasePacket {

	private static final String C_EXIT_GHOST = "[C] C_ExitGhost";
	private static final Logger _log = Logger.getLogger(C_ExitGhost.class.getName());
	@Override
	public String getType() {
		return C_EXIT_GHOST;
	}

	// 移動
	@Override
	public void start(final byte[] decrypt, final ClientThread client) {
		try {
			// 資料載入
			this.read(decrypt);

			final L1PcInstance pc = client.getActiveChar();
			if (pc == null ||!pc.isGhost()) {
				return;
			}

			pc.makeReadyEndGhost();
		} catch (final Exception e) {
			_log.log(Level.SEVERE, e.getLocalizedMessage(), e);

		} finally {
			this.over();
		}
	}
}